package com.kaoshi.myweb.web.controller.searchablebind;

import com.alibaba.fastjson.JSONObject;
import com.kaoshi.myweb.common.lib.pagehelper.Page;
import com.kaoshi.myweb.common.lib.pagehelper.PageInfo;
import com.kaoshi.myweb.web.controller.BaseCRUDController;
import com.kaoshi.myweb.web.entity.TestBlogDTO;
import com.kaoshi.myweb.web.entity.User;
import com.kaoshi.myweb.web.entity.search.SearchCondition;
import com.kaoshi.myweb.web.service.TestBlogService;
import com.kaoshi.myweb.web.web.argument.annotation.SearchConditionDefaults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2016/12/9.
 */
@Controller
@RequestMapping(value = "/test/search")
public class SearchConditionController extends BaseCRUDController<User, Long> {

	@Autowired
	private TestBlogService testBlogService;

	@RequestMapping(value = "/form",method = RequestMethod.GET)
	public String searchForm() {
		return "search/searchForm";
	}


	@RequestMapping(value = "/searchResult",method = RequestMethod.GET)
	@SearchConditionDefaults(sort = "id=desc")
	@ResponseBody
	public PageInfo<TestBlogDTO> searchForm22(SearchCondition searchCondition) {
		PageInfo<TestBlogDTO> page = testBlogService.queryByPage(searchCondition);
		return page;
	}

}
